package com.salim.leetcode.$121;

public class BestTimeToBuyAndSellStock {
    public int maxProfit(int[] prices) {
        int numMax = 0;
        int priceMax = 0;
        for(int i=prices.length-1;i>0;i--){
            numMax = Math.max(prices[i],numMax);
            priceMax = Math.max(numMax-prices[i-1],priceMax);
        }
        return priceMax;
    }
}
